home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / PD / Anwendungen / ToolManager / Source / Converter / menu.c < prev    next >
C/C++ Source or Header  |  1998-06-17  |  2KB  |  75 lines

  1. /*
  2.  * menu.c  V3.1
  3.  *
  4.  * ToolManager old preferences converter for Menu Objects
  5.  *
  6.  * Copyright (C) 1990-98 Stefan Becker
  7.  *
  8.  * This source code is for educational purposes only. You may study it
  9.  * and copy ideas or algorithms from it for your own projects. It is
  10.  * not allowed to use any of the source codes (in full or in parts)
  11.  * in other programs. Especially it is not allowed to create variants
  12.  * of ToolManager or ToolManager-like programs from this source code.
  13.  *
  14.  */
  15.  
  16. #include "converter.h"
  17.  
  18. /* Local data */
  19. static struct MenuDATAChunk mdc;
  20.  
  21. /* Old Prefs stuff */
  22. struct MenuPrefsObject {
  23.                         ULONG mpo_StringBits;
  24.                        };
  25. #define MOPO_NAME  (1L << 0)
  26. #define MOPO_EXEC  (1L << 1)
  27. #define MOPO_SOUND (1L << 2)
  28.  
  29. /* Conversion routine */
  30. #define DEBUGFUNCTION ConvertMenuConfig
  31. BOOL ConvertMenuConfig(void *chunk, struct IFFHandle *iffh, ULONG id)
  32. {
  33.  struct MenuPrefsObject *mpo = chunk;
  34.  char                   *s   = (char *) (mpo + 1);
  35.  BOOL                    rc  = FALSE;
  36.  
  37.  MENU_LOG(LOG3(Entry, "Chunk 0x%08lx IFF Handle 0x%08lx ID 0x%08lx",
  38.                chunk, iffh, id))
  39.  
  40.  /* Check that name is valid */
  41.  if (mpo->mpo_StringBits & MOPO_NAME) {
  42.   char *name = s;
  43.  
  44.   /* Skip name */
  45.   s += strlen(name) + 1;
  46.  
  47.   /* Initialize fixed data */
  48.   mdc.mdc_Standard.sdc_ID    = id;
  49.   mdc.mdc_Standard.sdc_Flags = 0;
  50.   mdc.mdc_ExecObject         = 0;
  51.   mdc.mdc_SoundObject        = 0;
  52.  
  53.   /* Find linked objects */
  54.   if (mpo->mpo_StringBits & MOPO_EXEC) {
  55.    mdc.mdc_ExecObject = FindExecID(s);
  56.    s += strlen(s) + 1;
  57.   }
  58.   if (mpo->mpo_StringBits & MOPO_SOUND)
  59.    mdc.mdc_SoundObject = FindSoundID(s);
  60.  
  61.   /* Create new config entry */
  62.   rc = (PushChunk(iffh, ID_TMMO, ID_FORM, IFFSIZE_UNKNOWN) == 0) &&
  63.        (PushChunk(iffh, 0,       ID_DATA, IFFSIZE_UNKNOWN) == 0) &&
  64.        (WriteChunkBytes(iffh, &mdc, sizeof(struct MenuDATAChunk))
  65.          == sizeof(struct MenuDATAChunk)) &&
  66.        (PopChunk(iffh) == 0) &&
  67.        (ConvertConfigString(name, iffh, ID_NAME) != NULL) &&
  68.        (PopChunk(iffh) == 0)  ;
  69.  }
  70.  
  71.  MENU_LOG(LOG1(Result, "%ld", rc))
  72.  
  73.  return(rc);
  74. }
  75.